<template>
  <div class="cart.vue cart">
    <div class="header">
      <img
        @click="$router.back(-1)"
        :src="require('@/assets/imgs/icons/arr-l.png')"
        alt
        class="head-icon head-search"
      >
      <h2 class="head-zaowu">购物车</h2>
      <div class="head-icons">编辑</div>
    </div>

    <ul class="my-cart-lists clearfix">
      <li class="my-cart-item" v-for="buy in buyList" :key="buy.id">
        <input type="checkbox" v-model="buy.checked" class="radio fl">
        <img :src="buy.img" alt class="my-cart-goodsImg fl">
        <div class="my-goods-msg fl">
          <p class="my-goods-msg-item">{{buy.cname}}</p>
          <p class="my-goods-msg-item my-goods-name">{{buy.name}}</p>
          <p class="my-goods-msg-item my-monay">¥{{buy.monay}}</p>
        </div>
        <div class="my-quan">
          <span class="count my-count" @click="minusGoods(buy.id)">-</span>
          <span class="my-number">{{buy.count}}</span>
          <span class="count" @click="plusGoods(buy.id)">+</span>
        </div>
        <!-- <div class="ceshi">{{buy.total}}</div> -->
      </li>
    </ul>

    <div class="foot">
      <!-- <div class="foot-bg"></div> -->
      <div class="foot-bar foot-top">
        <ul class="foot-top-lists">
          <li class="foot-top-item">
            <input type="checkbox" name id class="foot-top-collect">
            <!-- <img :src="require('@/assets/imgs/icons/like.png')" alt class="foot-top-collect"> -->
          </li>
          <li class="foot-top-item">
            <p class="top-item-txt">全选</p>
          </li>
          <li class="foot-top-item oot-top-monay">
            <p class="top-item-all">
              总计
              <span class="item-monay">{{max}}</span>
            </p>
          </li>
          <li class="foot-top-item foot-top-item-bar">
            <div class="foot-top-go foot-top-maimai">立即购买</div>
          </li>
        </ul>
      </div>
      <div class="foot-bar foot-bottom">
        <div class="foot-bottom-lin"></div>
      </div>
    </div>
  </div>
</template>

<script>
import Mack from "mockjs";
const Random = Mack.Random;
export default {
  name: "cart.vue",

  data() {
    return {
      chkbox: true
    };
  },
  computed: {
    buyList() {
      return this.$store.getters["cart/buyList"];
      
      // return this.$store.state.cart.cartGoods;
    },
    max() {
      return this.$store.getters["cart/max"];
      // return this.$store.state.cart.cartGoods;
    }
    // goodsMy(){
    //   for(var i = 0; i < buyList.length; i ++){
    //     return buyList[i].monay*buyList[i].count
    //   }
    // }
  },
  methods: {
    
    plusGoods(id) {
      this.$store.commit("cart/getPulsGoods", id);
    },
    minusGoods(id) {
      this.$store.commit("cart/minusGoods", id);
    },
    getGoods() {
      // goodsBar = JSON.stringify(this.goodsMsg)
      // this.goodsMsg.push(this.$route.params.goodsMsg);
      // this.$route.params.goodsMsg
      console.log(this.goodsMsg);
    }
  },
  created() {
    // this.getGoods();
  }
};
</script>

<style lang='scss' scoped>
@import "@/assets/style/commin.scss";
.cart {
  background-color: #f4f4f4;
  .header {
    display: flex;
    padding: 0 $basPadding;
    justify-content: space-between;
    align-items: center;
    // background-color: pink;
    // margin-bottom: 13.5px;
    width: 100%;
    height: 28px;
    .head-zaowu {
      font-size: 20px;
      color: #000;
      padding-left: 20px;
    }
    .head-icons {
      font-size: 16px;
      color: #010e0d;
    }
    .head-icon {
      width: 20px;
      height: 20px;
    }
  }
  .my-cart-lists {
    .my-cart-item {
      position: relative;
      width: 333px;
      height: 114px;
      background-color: #fff;
      margin: 24.5px auto;
      .radio {
        position: absolute;
        top: 50%;
        left: 0;
        margin-top: -8.5px;
        width: 17px;
        height: 17px;
        border: 0 solid #e5e5e5;
      }
      .my-cart-goodsImg {
        width: 76px;
        height: 76px;
        position: absolute;
        top: 50%;
        margin-top: -38px;
        left: 31px;
      }
      .my-goods-msg {
        margin-left: 144px;
        margin-top: 26.5px;
        .my-goods-item .my-goods-name {
          margin: 6.5px 0;
        }
        .my-goods-msg-item {
          font-size: 12px;
          color: #494949;
          line-height: 17px;
        }
        .my-monay {
          font-size: 14px;
          color: #1c4b47;
          left: 22px;
        }
      }
      .my-quan {
        position: absolute;
        top: 72.5px;
        right: 13.5px;
        .my-count {
          padding-left: 100px;
        }
        .count {
          color: #e5e5e5;
          font-size: 14px;
        }
        .my-number {
          font-size: 14.52px;
          color: #000;
          margin: 0 7.5px;
        }
      }
    }
  }
  .foot {
    position: fixed;
    bottom: 0;
    height: 82.5px;
    width: 100%;
    z-index: 999;
    // background-color: pink;
    .foot-bg {
      width: 375px;
      height: 400px;
      background-color: #a6b4a3;
    }
    .foot-bottom-lin {
      width: 134px;
      height: 5px;
      background-color: #000;
      margin: 0 auto;
      margin-top: 20px;
    }
    .foot-bar {
      width: 100%;
      height: 50%;
      padding: 0 $basPadding;
      &.foot-top {
        .foot-top-lists {
          position: relative;
          .oot-top-monay {
            margin-left: 51px;
            margin-top: 12px;
            color: #010e0d;
            font-size: 14px;
            .item-monay {
              color: #1c4b47;
              font-size: 16px;
              margin-left: 15px;
            }
          }
          .foot-top-item {
            float: left;
            .top-item-txt {
              font-size: 18px;
              color: #010e0d;
              margin-top: 12.5px;
            }

            .foot-top-collect {
              margin-top: 7px;
              width: 27px;
              height: 27px;
              margin-right: 21px;
            }

            .foot-top-maimai {
              float: left;
              width: 113px;
              height: 40px;
              border: 1px solid #1c4b47;
              border-radius: 4px;
              text-align: center;
              line-height: 40px;
              color: #1c4b47;
              font-size: 15px;
            }

            &.foot-top-item-bar {
              position: absolute;
              right: 0;
            }
          }
        }
      }
    }
  }
}
</style>
